import md5 from "./md5.js"
module.exports = (params,domain,url)=> {
	let sign = ''
	let newData = JSON.parse(JSON.stringify(params));
	// newData.key= 'MINGYANGB7D0C9D279892857DE5490AB856772FE' //口令
	newData.domain=domain//域名
	newData.pathinfo=url//接口地址
	newData.timestamp=new Date().getTime()//当前时间戳
	sign = objKeySort(newData) + '&key=6J()4_U[GDufC7e#~BRYX,&yO"M`-t|^w:ro>n8iFKQW=H<T%Sq5LAEIa0$bNvcp'
	// sign = '123456'md5(sign)
	return {
		// md5(sign)
		sign: md5(sign),
		timestamp:newData.timestamp,
	}
	
}
function objKeySort(obj) {//排序的函数
    var newkey = Object.keys(obj).sort();
    var newObj = '';
    for (var i = 0; i < newkey.length; i++) {
        // newObj[newkey[i]] = obj[newkey[i]];
        newObj =newObj+`&${[newkey[i]]}=${obj[newkey[i]]}`;
    }
    return newObj.substring(1);
}